//
//  YMSG9Packet.h
//  HelloWorld
// *********************************************************************
// This class is nothing more than a convenient data structure to hold
// the information extracted from a single YMSG packet (message).  The
// body array holds the list of strings, in sequence, as they appeared
// in the body section of the packet.
//
// This class is returned by YMSG9InputStreamReader.readPacket();
// See YMSG9InputStream.java for more details on the protocol.
//
// Note: the term 'packet' here is strictly speaking incorrect, as a
// YMSG message could in theory take up more than one TCP packet - but
// it helps to distinguish these lower-level network messages from
// the higher-level dialogue 'message's in the protocol.
// *********************************************************************
//  Created by Martin Le C. on 5/14/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface YMSG9Packet : NSObject {
	NSString *magic;
	UInt32 version;
	UInt16 length;
	UInt16 service;
	UInt32 status;
	UInt32 sessionId; // using for connecting through HTTP proxy 
	NSMutableArray *body;
}
@property (nonatomic, assign) NSString *magic;
@property (nonatomic, assign) UInt32 version;
@property (nonatomic, assign) UInt16 length;
@property (nonatomic, assign) UInt16 service;
@property (nonatomic, assign) UInt32 status;
@property (nonatomic, assign) UInt32 sessionId;
@property (nonatomic, assign) NSMutableArray *body;
-(NSInteger) getNthLocation:(NSString*)k n:(NSInteger)n;
-(NSString*) getNthValue:(NSString*)k n:(NSInteger)n;
-(NSString*) getValue:(NSString*)k;
-(NSMutableArray*) getValues:(NSString*)k;
-(NSString*) getValueFromNthSet: (NSString*)set k:(NSString*)k n:(NSInteger)n;
-(BOOL)exists:(NSString*)k;
-(void)append: (YMSG9Packet*)pkt;
-(void)merge:(YMSG9Packet*) pkt concatFields:(NSMutableArray*) concatFields;
-(NSString*)toString;
@end